using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class SafeAreaWidth : MonoBehaviour
{
    private float width = 40;
    void Start()
    {
        GetWidth(); // 调用函数并指定初始等待时间、重复间隔 GetWidth();

    }
    void Update()
    {      
        Debug.Log("###width  :" + width);
    }
    public void GetWidth()
    {
        System.Object[] arr = { new OpenHarmonyJSCallback(new JSCallbackFunc(WidthCallback)) };
        OpenHarmonyJSObject openharmonyJSObject = new OpenHarmonyJSObject("SafeAreaWidth");
        openharmonyJSObject.Call("calculateSafeAreaWidth",arr);
        Debug.Log("###width333  :" + width);   
    }
    private void WidthCallback(params OpenHarmonyJSObject[] args)
    {
        width = args[0].As<float>();
        Debug.Log("###width  :" + width);
    }

}
